package com.sq.shortlink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sq.shortlink.admin.common.convension.result.Result;
import com.sq.shortlink.admin.remoto.ShortLinkRemoteService;
import com.sq.shortlink.admin.remoto.dto.req.ShortLinkCreateReqDTO;
import com.sq.shortlink.admin.remoto.dto.req.ShortLinkPageReqDTO;
import com.sq.shortlink.admin.remoto.dto.resp.ShortLinkCreateRespDTO;
import com.sq.shortlink.admin.remoto.dto.resp.ShortLinkPageRespDTO;
import org.springframework.web.bind.annotation.*;

/**
 * 短链接控制层
 * @author quan
 */
@RestController
@RequestMapping("/api/short-link/admin/v1")
public class ShortLinkController {
    private final ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService() {
    };

    /**
     * 创建短链接
     */
    @PostMapping("/create")
    public Result<ShortLinkCreateRespDTO> createShortLink(@RequestBody ShortLinkCreateReqDTO requestParam){
        return shortLinkRemoteService.createShortLink(requestParam);
    }

    /**
     * 短链接分页查询
     */
    @PostMapping("/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(@RequestBody ShortLinkPageReqDTO requestParam){
        return shortLinkRemoteService.pageShortLink(requestParam);
    }
}
